//
// Created by fys on 2020/5/14.
//

#ifndef NETWORK_COMMON_TTCP_H
#define NETWORK_COMMON_TTCP_H

#include <stdbool.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <error.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <poll.h>
#include <wait.h>
#include <pthread.h>
#include <sys/uio.h>
#include <sys/timeb.h>
#include "string.h"
#include "stdint.h"
#include "assert.h"

typedef struct Options
{
    int length;
    int number;
    uint16_t port;
    bool transmit, receive, nodelay;  // not used now
    char* host;
} Options;

typedef struct SessionMessage
{
    int32_t number;
    int32_t length;
} SessionMessage;

typedef struct PayloadMessage
{
    int32_t length;
    char data[0];
} PayloadMessage;

void transmit(const Options* opt);
void receive(const Options* opt);

size_t readn(int, void*, size_t);
size_t writen(int, void*, size_t);

#endif
